

MZView = function(options){
	return this.init(options);
}


MZView.fn = MZView.prototype = {
    
    dom : null,
	type : "",
    url : "",
    data: null,
    fieldSetting: []

}


MZView.fn.init = function(options){
    var that = this;
    Object.assign(that, options);

    if(that.type == 'item'){
        that._render_item(that.data);
    }

}


MZView.fn._get_field_name = function(fieldName) {
    for( var i in this.fieldSetting ){
        var item = this.fieldSetting[i];
        if(fieldName == item.name) {
            return item.title;
        }
    }
    return fieldName;
}

MZView.fn._render_item = function(data) {
    if(!data){
        return;
    }


    for (var key in data) {
        var ele = document.createElement('div');
        var name = this._get_field_name(key);
        ele.className = 'layui-row item';
        var tmpHtml = '<div class="layui-col-sm4 title"> ' + name + ' :</div>';
        tmpHtml += '<div class="layui-col-sm8 desc">' + (data[key] || '' ) + ' </div>';
        ele.innerHTML = tmpHtml;
        this.dom.appendChild(ele);
    }
    
}

